# -*- coding: utf-8 -*-
import os
from flask import Flask
from flask_login  import LoginManager
from flask_bcrypt import  Bcrypt
from flask_cache import Cache
from flask_pymongo import PyMongo
from flask_mongoengine import  MongoEngine,MongoEngineSessionInterface
from flask_debugtoolbar import DebugToolbarExtension
from celery import Celery



# Create and name Flask app
app = Flask(__name__)
app.config['MONGODB_SETTINGS'] = {'HOST':'127.0.0.1','DB':'avmo'}
app.config['SECRET_KEY'] = os.environ.get('SECRET_KEY',"dshkwnds")
app.debug = os.environ.get('DEBUG',True)
#toolbar = DebugToolbarExtension(app)
db = MongoEngine(app)
app.session_interface = MongoEngineSessionInterface(db)


cache = Cache(app,config={'CACHE_TYPE':'simple'})
app.config['MONGO_URI'] = 'mongodb://localhost:27017/avmo'
mongo = PyMongo(app, config_prefix='MONGO')
celery = Celery('backends.tasks',broker='amqp://guest:guest@localhost:5672//')

flask_bcrypt = Bcrypt(app)
login_manager = LoginManager()
login_manager.init_app(app)





